package com.hsu.hiring.talent.dao;

import java.util.List;

import com.hsu.hiring.common.util.DBUtil;
import com.hsu.hiring.talent.entity.ResumeEntity;

/**
 * Dao(Data Access Object)：执行所有数据库的操作
 *
 * @author Hsu.
 * @since 2016年1月11日
 */
public class ResumeDao {

	/**
	 * 简历新增
	 * 
	 * @param resumeEntity
	 * @return
	 */
	public int add(ResumeEntity resumeEntity) {
		int row = DBUtil.executeUpdate(
				"INSERT INTO resume VALUES(NULL, ?, ?, ?, ?)",
				resumeEntity.getTalentId(), resumeEntity.getIntention(),
				resumeEntity.getWorkExperience(),
				resumeEntity.getProjectExperience());
		return row;
	}

	/**
	 * 简历查询
	 * 
	 * @param resumeEntity
	 * @return
	 */
	public List<ResumeEntity> list() {
		List<ResumeEntity> resumeList = DBUtil
				.executeQuery(
						ResumeEntity.class,
						"SELECT t.name, r.intention, r.work_experience, r.project_experience FROM resume r, talent t WHERE t.id=r.talent_id");
		return resumeList;
	}
}
